//package ay.shadow.shadowgateway.handler;
//
//import com.alibaba.cloud.commons.lang.StringUtils;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.util.Base64Utils;
//import org.springframework.web.servlet.HandlerInterceptor;
//import reactor.util.annotation.NonNull;
//
//public class ShadowServerInterceptor implements HandlerInterceptor {
//
////    private CloudSecurityProperties properties;
//
//    @Override
//    public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler){
//
////        if (!properties.getOnlyFetchByGateway()) {
////            return true;
////        }
//
//        String token = request.getHeader(CloudConstant.GATEWAY_TOKEN_HEADER);
//
//        String gatewayToken = new String(Base64Utils.encode(CloudConstant.GATEWAY_TOKEN_VALUE.getBytes()));
//
//        if (StringUtils.equals(gatewayToken, token)) {
//            return true;
//        } else {
//            ResultData<String> resultData = new ResultData<>();
//            resultData.setSuccess(false);
//            resultData.setStatus(HttpServletResponse.SC_FORBIDDEN);
//            resultData.setMessage("请通过网关访问资源");
//            WebUtils.writeJson(response,resultData);
//            return false;
//        }
//    }
//
//    public void setProperties(CloudSecurityProperties properties) {
//        this.properties = properties;
//    }
//}
//
